<%-- 
    Document   : db2
    Created on : 2014/8/19, 下午 01:26:16
    Author     : Felix
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb","root","root");
        Statement st = con.createStatement();
        String username = request.getParameter("username");//獲取資料
        String tel = request.getParameter("tel");
        String birthday = request.getParameter("birthday");
        String id = request.getParameter("id");
        //String sql="insert into person(username,tel,birthday) values('Tom','02-222222','2050/01/01')";
        String sql="update person set username='"+username+"', tel='"+tel+"' ,birthday='"+birthday+"' where id="+id;//sql修改語法
        int x = st.executeUpdate(sql);//設定變數並更新選定的一筆資料
        st.close();
        con.close();
    %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <%=x%>
        <a href="list.jsp">list</a>
    </body>
</html>
